import { toast } from "../../utils/storage"
Page({
  data: {
    feedback: '',
    loading: false
  },
  goback() {
    wx.navigateBack();
  },
  onLoad(options) {
  },
  async submit() {
    if (this.data.loading)
      return;
    if (this.data.feedback.trim() === '') {
      toast({ title: "请输入反馈信息", duration: 2000 });
      return;
    }
    else if (this.data.feedback.trim().length > 100) {
      toast({ title: "您的反馈信息过多" });
      return;
    }
    this.setData({ loading: true });
    let { statusCode, data: { code, message, status } } = await wx.$http.post("/quality/mgr/feedBackInfo", { "opinion": this.data.feedback }).catch();
    this.setData({ loading: false });
    if (statusCode === 200 && code === 200 && status) {
      toast({ title: message });
      this.setData({ feedback: '' });
    }
    else
      toast({ title: "操作异常，请重试" });
  }
})